//AssignTableClass
(function ($) {
    $.fn.assignTableClass = function (settings) {
        var holder = $(this);
        var defaults = {
            makeHover: true,
            emptyCaption: "",
            white_space: "nowrap",
            colspan: 0,
        };
        var options = jQuery.extend(defaults, settings);

        //clear Alpha
        //$(holder).find("td").removeAttr('style');
        //empty row
        if (!$(holder).find("tbody tr").size()) {
            if (options.emptyCaption ==  "") { emptyCaption = "Empty Data" }
            if (options.colspan == "") {
                options.colspan = $(holder).find("thead tr:first").find("th").size();
            }
            $(holder).find("tbody").append('<tr class="emptyRow"><td align="center" style="height:50px" colspan="' + options.colspan + '">' + emptyCaption + '</td></tr>')
        }
        //add class
        if ($(holder).is("table")) {//Direct assign to table 
            if(options.white_space == "nowrap"){
                $(holder).attr({ cellspacing: 0, cellpadding: 4 }).addClass("tw-ui-makeList ui-widget ui-widget-content")
		        .css({ 'white-space': 'nowrap' })
		        .find("th").addClass("ui-widget-header")
		        .end().find("td").addClass("ui-widget-content");
            }else{
                $(holder).attr({ cellspacing: 0, cellpadding: 4 }).addClass("tw-ui-makeList ui-widget ui-widget-content")
		        .find("th").addClass("ui-widget-header")
		        .end().find("td").addClass("ui-widget-content");
            }

        } else { //assign to holder
            $(holder).find("table").attr({ cellspacing: 0, cellpadding: 4 }).addClass("tw-ui-makeList ui-widget ui-widget-content")
		.css({ 'white-space': 'nowrap' })
		.find("th").addClass("ui-widget-header")
		.end().find("td").addClass("ui-widget-content");
        }
        //.end().find("tr:even td").css({ opacity: .90, filter: 'Alpha(Opacity=90)' });

        //hover
        if (options.makeHover==true) {
            $(holder).find("tbody tr").hover(
		  function () {
		      $(this).find("td").addClass("ui-state-focus");
		  }, function () {
		      $(this).find("td").removeClass("ui-state-focus");
		  }
		);
        }
    }
})(jQuery);